package com.huawei.statistics.collection;

import com.huawei.statistics.utils.HttpUtils;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by 18573 on 2018/12/8.
 */
public class ArticleCollection {








    //文章采集
    public static Map<String,String> getVideoList(String url){
        String entity = HttpUtils.getResultEntity(url, null, null, HttpUtils.GET);
        Document doc = Jsoup.parse(entity);
        Elements elements=doc.select("div[class=content-list]");
        Element element = elements.get(0);
        String title = element.select("h1[class=view-title]").text();
        String descri = element.select("p[class=d-for]").text();
        String context = element.select("div[class=view-des]").html();
        Map<String,String> map = new HashMap<>();
        map.put("title",title);
        map.put("descript",descri);
        map.put("context",context);
        return map;

    }


    public static void main(String[] args) {

        Map<String,String> map = getVideoList("http://www.cnhnb.com/xt/article-2789.html");
        System.out.println("惠农网标题======="+map.get("title"));
        System.out.println("描述======="+map.get("descript"));
        System.out.println("内容========"+map.get("context"));
    }






}
